import java.util.Scanner;

public class LongShort {
    public static void main(String[] args) {
        String[]str=new String[5];
        Scanner scanner=new Scanner(System.in);
        int i=0;
        while(i<5){
            str[i]=scanner.nextLine();
            i++;
        }
        int max=0;
        int min=1;
        for (int j = 0; j < str.length; j++) {
            if(str[j].length()>str[max].length()){
                max=j;
            }else if(str[j].length()<str[min].length()){
                min=j;
            }
        }
        System.out.println("最长str= "+str[max]);
        System.out.println("最段str= "+str[min]);
    }
}
